package com.power.sifa.correction.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import com.power.sifa.correction.model.Crc_group_person;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;

/**
 * 社区矫正分组内人员 持久层(hibernate)
 */

public interface Crc_group_personDao extends JpaRepository<Crc_group_person, Serializable>, JpaSpecificationExecutor<Crc_group_person>, Repository<Crc_group_person, Serializable>, Crc_group_personDaoCustom<Crc_group_person, Serializable> {

   @Modifying
   @Transactional
   @Query("delete  from Crc_group_person s where  s.id in (:ids) ")
   void removeByIds(@Param("ids") List<Integer> ids);


   @Query(" from Crc_group_person s where s.grpid in (:groupIds) ")
   List<Crc_group_person> findByGroupIds(@Param("groupIds") List<String> groupIds);

   @Query(" from Crc_group_person s where s.perid in (:personIds) ")
   List<Crc_group_person> findByPersonIds(@Param("personIds") List<String> personIds);

   @Modifying
   @Transactional
   @Query(" delete from Crc_group_person s where s.grpid in (:groupIds) ")
   void removeByGroupId(@Param("groupIds") List<String> groupIds);

   @Modifying
   @Transactional
   @Query(" delete from Crc_group_person s where s.perid =:personId and s.grpid = :groupId")
   void removeByPersonId(@Param("personId") String personId, @Param("groupId") String groupId);
}
